{extend name="public/base" /}

{block name="title"}<title>{if condition="$data"}{$Think.lang.edit}{else /}{$Think.lang.create}{/if}</title>{/block}

{block name="pjax_container"}
<div class="hry-content-wrapper">
    <section class="content-header">
        <ol class="breadcrumb">
            <li>项目管理</li>
            <li class="active">轮播图管理</li>
        </ol>
    </section>
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <form class="form-horizontal" method="POST" action="" onsubmit="return false"  >
                    <div class="nav-tabs-custom">
                        <div class="tab-content">
                            <div class="tab-pane active" id="tab_base">
                                <input type="hidden" name="id" value="{$data.id}" />
                                <div class="form-group">
                                    <label class="col-sm-2 control-label hry-require">位置</label>
                                    <div class="col-sm-7">
                                        <div class="input-group" style="width: 100%" >
                                            <select class="form-control" name="sort" id="position" value="{$data.sort}" style="width: 100%" >
                                                <option value="1" {if condition=" $data.sort == 1 "}selected="selected"{/if}>1号位</option>
                                                <option value="2" {if condition=" $data.sort == 2 "}selected="selected"{/if}>2号位</option>
                                                <option value="3" {if condition=" $data.sort == 3 "}selected="selected"{/if}>3号位</option>
                                                <option value="4" {if condition=" $data.sort == 4 "}selected="selected"{/if}>4号位</option>
                                                <option value="5" {if condition=" $data.sort == 5 "}selected="selected"{/if}>5号位</option>
                                                <option value="6" {if condition=" $data.sort == 6 "}selected="selected"{/if}>6号位</option>
                                                <option value="7" {if condition=" $data.sort == 7 "}selected="selected"{/if}>7号位</option>
                                                <option value="8" {if condition=" $data.sort == 8 "}selected="selected"{/if}>8号位</option>
                                                <option value="9" {if condition=" $data.sort == 9 "}selected="selected"{/if}>9号位</option>
                                                <option value="10" {if condition=" $data.sort == 10 "}selected="selected"{/if}>10号位</option>
                                                <option value="11" {if condition=" $data.sort == 11 "}selected="selected"{/if}>11号位</option>
                                                <option value="12" {if condition=" $data.sort == 12 "}selected="selected"{/if}>12号位</option>
                                                <option value="13" {if condition=" $data.sort == 13 "}selected="selected"{/if}>0号位(不显示)</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label hry-require">标题</label>
                                    <div class="col-sm-7">
                                        <div class="input-group"  style="width: 100%">
                                            <input class="form-control" id="title" name="title" value="{$data.title}" placeholder=""  style="width: 100%">
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label hry-require">（W:382 H:370）项目轮播图</label>
                                    <div class="col-sm-7">
                                        <div class="input-group">
                                            <input class="form-control" name="picture" id="pic" value="{$data.picture}" placeholder="项目缩略图" >
                                            <span class="input-group-btn">
                                                <a href="{$data.picture|default='/static/global/face/no-image.png'}" target="_blank" >
                                                    <img src="{$data.picture|default='/static/global/face/no-image.png'}" style="height:34px; width:68px;" />
                                                </a>
                                                <button class="btn btn-success btn-flat up-btn" type="button" data-url="{:url('Uploads/upload')}?dir=project">
                                                    <i class="fa fa-cloud-upload"> {$Think.lang.Upload}</i>
                                                </button>
                                            </span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="box-footer">
                            <div class="col-sm-2"></div>
                            <div class="col-sm-7">
                                <div class="btn-group pull-right">
                                    <button type="submit" onClick="return toVaildate(event)" class="btn btn-info pull-right submits" data-loading-text="&lt;i class='fa fa-spinner fa-spin '&gt;&lt;/i&gt; {$Think.lang.submit}">{$Think.lang.submit}</button>
                                </div>
                                <div class="btn-group pull-left">
                                    <button type="reset" class="btn btn-warning">{$Think.lang.reset}</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </section>
</div>
<script type="text/javascript">
    function toVaildate(event) {
        let position = $('#position').val()
        let title = $('#title').val()
        let pic = $('#pic').val()
        let validate = false
        if (position === '' || title === '' || pic === '') {
            $.amaran({'message': '请输入完整信息!'});
            event.preventDefault();
            event.stopPropagation();
        } else {
            validate = true
        }
        return validate
    }
    $(function(){
        /*ajax页面加载icheck，有该控件的页面才需要*/
        $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
            checkboxClass: 'icheckbox_minimal-blue',
            radioClass: 'iradio_minimal-blue'
        });

        /*ajax页面加载icheck，有该控件的页面才需要*/
        $(".select2").select2({language:"zh-CN"});

        $('.timepicker').datetimepicker({
            format: 'YYYY-MM-DD',   //YYYY-MM-DD HH:mm:ss
            locale: moment.locale('zh-cn')
        });

        {if condition=" $rest_login == 1 "}
        restlogin('{$rest_login_info}');   //登录超时
        {/if}
        })
</script>
{/block}